<%@ page pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/includes/directives/page.jspf"%>
<%@ include file="/WEB-INF/views/includes/directives/taglib.jspf"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<link rel="StyleSheet" href="css/general.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><fmt:message key="users_list_jsp.title" /></title>

</head>
<body>
	<div id="main_container">
		<%@ include file="/WEB-INF/views/includes/header.jspf"%>
		<div id="content">
			<table border='1'>
				<tr>
					<td>id</td>
					<td><fmt:message key="users_list_jsp.table.header.user_email" /></td>
					<td><fmt:message key="users_list_jsp.table.header.user_first_name"/></td>
					<td><fmt:message key="users_list_jsp.table.header.user_last_name"/></td>
					<td><fmt:message key="users_list_jsp.table.header.user_phone"/></td>
					<td><fmt:message key="users_list_jsp.table.header.user_reg_date"/></td>
					<td><fmt:message key="users_list_jsp.table.header.user_role"/></td>
					<td></td>
				</tr>
				<c:forEach items="${usersList}" var="user">
					<tr>
						<td>${user.id}</td>
						<td>${user.email}</td>
						<td>${user.firstName}</td>
						<td>${user.lastName}</td>
						<td>${user.phone}</td>
						<td><fmt:formatDate value="${user.registrationDate}" type="both" /></td>
						<td>
							<c:choose>
								<c:when test="${user.role == 'USER'}">
									<fmt:message key="users_list_jsp.table.role.user" />
								</c:when>
								<c:when test="${user.role == 'BANNED'}">
									<fmt:message key="users_list_jsp.table.role.banned" />
								</c:when>
								<c:when test="${user.role == 'ADMIN'}">
									<fmt:message key="users_list_jsp.table.role.admin" />
								</c:when>
							</c:choose>
						</td>
						<c:choose>
							<c:when test="${user.role == 'BANNED'}">
								<td>
									<a href="main?command=unban_user&userId=${user.id}">
										<fmt:message key="users_list_jsp.table.header.unban_user"/>
									</a>
								</td>
							</c:when>
							<c:otherwise>
								<td>
									<a href="main?command=ban_user&userId=${user.id}">
										<fmt:message key="users_list_jsp.table.header.ban_user"/>
									</a>
								</td>
							</c:otherwise>
						</c:choose>
					</tr>
				</c:forEach>
			</table>
		</div>
		<div id="free_space"></div>
	</div>

	<%@ include file="/WEB-INF/views/includes/footer.jspf"%>
</body>
</html>